package com.util;

import java.util.ArrayList;
import java.util.List;

public class Page<T> {
    private int pageIndex;
    private int pageSize = 5;
    private int totalPage;
    private int totalPageSize;
    private List<T> list = new ArrayList<>();

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        if(pageIndex<=1){
            this.pageIndex = 1;
        }else if(pageIndex>this.totalPageSize){
            this.pageIndex = this.totalPageSize;
        }else{
            this.pageIndex = pageIndex;
        }
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getTotalPageSize() {
        return totalPageSize;
    }

    public void setTotalPageSize() {
        this.totalPageSize = (this.totalPage%this.pageSize==0) ? totalPage/pageSize : (totalPage/pageSize)+1;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
